package com.netease.main;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.netease.dao.User;
import com.netease.service.UserService;

public class Main {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext(
                "applicationContext.xml");
        UserService userService = (UserService) context.getBean("userService");
        System.out.println(userService.countAll());

        System.out.println(userService.getNameById(1));

        List<User> users = userService.getAll();
        System.out.println(users.size());
        for (User user: users) {
            System.out.println("ID: " + user.getUserId() + "/ Name: "
                    + user.getUserName() + "/ Age: " + user.getUserAge());
        }
        /*
         * User test = new User(); test.setUserName("sunny");
         * test.setUserAge(25); userService.add(test);
         */
    }
}
